package com.sevntu.apvs.lab1;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class PrintOutputDataToFile {
	private BufferedWriter outputFileName = null;

	public PrintOutputDataToFile(final String graphDataOutputFileName) {
		try {
			outputFileName = new BufferedWriter(new FileWriter(
					graphDataOutputFileName));
		} catch (IOException e) {
		}
	}

	public void printResult(final byte graphArcGreaterN[]) {
		try {
			outputFileName
					.write("A list of nodes which have a number of arcs greater than given one:\n");
			for (int index = 0; index < graphArcGreaterN.length; index++) {
				outputFileName.write(graphArcGreaterN[index] + " ");
			}
		} catch (IOException e) {

		} finally {
			if (null != outputFileName)
				try {
					outputFileName.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
		}
	}

	public void printResult(final byte graphArcGreaterN[], final int nodeSum) {
		try {
			outputFileName
					.write("A list of nodes which have a number of arcs greater than given one:\n");
			for (int index = 0; index < graphArcGreaterN.length; index++) {
				outputFileName.write(graphArcGreaterN[index] + " ");
			}
			outputFileName.write("\nNumbers of nods: " + nodeSum);
		} catch (IOException e) {
			System.err.println("Error in opening file!!");
		} finally {
			if (null != outputFileName)
				try {
					outputFileName.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
		}
	}
}
